package com.ashbur.SelectionSort;

/**
 * @author : Eumenides
 * @Description :
 * @date : 2022/7/18
 * @Copyright ： 公众号：菜鸟的大厂梦
 */
public class Student implements Comparable<Student> {

    private String name;
    private int score;

    public Student(String name, int score){
        this.name = name;
        this.score = score;
    }

    @Override
    public int hashCode() {
        int result = name.hashCode();
        result = 31 * result + score;
        return result;
    }

    @Override
    public boolean equals(Object student){

        if(this == student) {
            return true;
        }

        if(student == null) {
            return false;
        }

        if(this.getClass() != student.getClass()) {
            return false;
        }

        Student another = (Student)student;
        return this.score == another.score;
    }

    @Override
    public String toString(){
        return String.format("Student(name: %s, score: %d)", name, score);
    }

    @Override
    public int compareTo(Student o) {
        return o.score - this.score;
    }
}
